<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page errorPage="../jsp/index.jsp?site=error" %>
<% 
Integer userid = (Integer) session.getAttribute("user_id");
Statement stmt;
ResultSet res;
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/studienarbeit";
Connection con = DriverManager.getConnection(url, "admin", "cisco");
stmt = con.createStatement();

String firstName ="";
String lastName ="";
String email = "";

try {
	res = stmt.executeQuery("SELECT first_name, last_name, email FROM users WHERE user_id = " + userid + ";");
	while(res.next()){
		firstName = res.getString("first_name");
		lastName = res.getString("last_name");
		email = res.getString("email");
	}
	con.close();
} catch (SQLException e) {
	con.close();
	
}
%>
<table>
	<tr>
		<td>Vorname: </td>
		<td><%= firstName %></td>
	</tr>
	<tr>
		<td>Nachname: </td>
		<td><%= lastName %></td>
	</tr>
	<tr>
		<td>Email: </td>
		<td><%= email %></td>
	</tr>
	<tr>
		<td><a href="<%= response.encodeURL("../jsp/index.jsp")%>">Zur Startseite</a></td>
		<td><a href="<%= response.encodeURL("../includejsp/doLogout.jsp")%>">Logout</a></td>
	</tr>
</table>
